package com.ruoyi.web.controller.community.notice;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.community.domain.SimpleNoticeSection;
import com.ruoyi.community.service.ISimpleNoticeSectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公告板块Controller
 * 
 * @author ruoyi
 * @date 2021-12-10
 */
@RestController
@RequestMapping("/community/notice/abandon/section")
public class SimpleNoticeSectionController extends BaseController
{
    @Autowired
    private ISimpleNoticeSectionService simpleNoticeSectionService;

    /**
     * 查询公告板块列表
     */
    @PreAuthorize("@ss.hasPermi('community:section:list')")
    @GetMapping("/list")
    public TableDataInfo list(SimpleNoticeSection simpleNoticeSection)
    {
        startPage();
        List<SimpleNoticeSection> list = simpleNoticeSectionService.selectSimpleNoticeSectionList(simpleNoticeSection);
        return getDataTable(list);
    }

    /**
     * 导出公告板块列表
     */
    @PreAuthorize("@ss.hasPermi('community:section:export')")
    @Log(title = "公告板块", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SimpleNoticeSection simpleNoticeSection)
    {
        List<SimpleNoticeSection> list = simpleNoticeSectionService.selectSimpleNoticeSectionList(simpleNoticeSection);
        ExcelUtil<SimpleNoticeSection> util = new ExcelUtil<SimpleNoticeSection>(SimpleNoticeSection.class);
        return util.exportExcel(list, "公告板块数据");
    }

    /**
     * 获取公告板块详细信息
     */
    @PreAuthorize("@ss.hasPermi('community:section:query')")
    @GetMapping(value = "/{sectionId}")
    public AjaxResult getInfo(@PathVariable("sectionId") String sectionId)
    {
        return AjaxResult.success(simpleNoticeSectionService.selectSimpleNoticeSectionById(sectionId));
    }

    /**
     * 新增公告板块
     */
    @PreAuthorize("@ss.hasPermi('community:section:add')")
    @Log(title = "公告板块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SimpleNoticeSection simpleNoticeSection)
    {
        return toAjax(simpleNoticeSectionService.insertSimpleNoticeSection(simpleNoticeSection));
    }

    /**
     * 修改公告板块
     */
    @PreAuthorize("@ss.hasPermi('community:section:edit')")
    @Log(title = "公告板块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SimpleNoticeSection simpleNoticeSection)
    {
        return toAjax(simpleNoticeSectionService.updateSimpleNoticeSection(simpleNoticeSection));
    }

    /**
     * 删除公告板块
     */
    @PreAuthorize("@ss.hasPermi('community:section:remove')")
    @Log(title = "公告板块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sectionIds}")
    public AjaxResult remove(@PathVariable String[] sectionIds)
    {
        return toAjax(simpleNoticeSectionService.deleteSimpleNoticeSectionByIds(sectionIds));
    }
}
